package org.duang.render;

import java.io.IOException;

import javax.servlet.ServletException;

import org.duang.config.Config;
import org.duang.config.InstanceFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JspRender extends Render {

	private static Logger logger = LoggerFactory.getLogger(JspRender.class);
	
	private static final long serialVersionUID = -7170413556280877767L;
	
	public JspRender(String view, String extname) {	
		this.view = (InstanceFactory.getServletContext().getContextPath() + Config.getViewRootPath() + view + extname).trim();
	}
	
	@Override
	public void render() {
		try {
			logger.debug("JspRender: " + view);				
			request.getRequestDispatcher(view).forward(request, response);
			return;
		} catch (ServletException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
